package com.dingwen.stusprbooes.service.impl;

import com.dingwen.stusprbooes.dao.GoodsDao;
import com.dingwen.stusprbooes.entity.GoodsEntity;
import com.dingwen.stusprbooes.service.GoodsService;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.index.IndexResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * GoodsService impl
 *
 * @author dingwen
 * 2021/6/27 21:45
 **/
@Service
public class GoodsServiceImpl implements GoodsService {
    private final GoodsDao goodsDao;

    @Autowired
    public GoodsServiceImpl(GoodsDao goodsDao) {
        this.goodsDao = goodsDao;
    }

    @Override
    public IndexResponse save(GoodsEntity goodsEntity) throws IOException {
        return goodsDao.save(goodsEntity);
    }

    @Override
    public BulkResponse save() throws IOException {
        return goodsDao.save();
    }

    @Override
    public DeleteResponse removeById(String id) throws IOException {
        return goodsDao.removeById(id);
    }

    @Override
    public List<Map<String, Object>> searchPageForHighlight(String keywords, int pageNo, int pageSize) throws IOException {
        return goodsDao.searchPageForHighlight(keywords,pageNo,pageSize);
    }


}
